package com.qianfeng.conf;

import com.qianfeng.conf.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Martin
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    // 这个方法是用来配置静态资源的
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    //获取拦截器实例
    private TokenInterceptor getTokenInterceptor(){
        return new TokenInterceptor();
    }

    // 这个方法用来注册拦截器，自定义拦截器需要通过这里添加注册才能生效

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(getTokenInterceptor()).excludePathPatterns("/static/*").addPathPatterns("/**");
    }


}
